package com.cskaoyan.app.controller;


import com.cskaoyan.app.bean.common.BasePageInfo;
import com.cskaoyan.app.bean.common.BaseRespVo;
import com.cskaoyan.app.bean.common.CommonData;
import com.cskaoyan.app.bean.po.MarketComment;
import com.cskaoyan.app.service.AdminCommmentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("admin/comment")
public class AdminCommentController {

    @Autowired
    AdminCommmentService adminCommmentService;

    //page=1&limit=20&sort=add_time&order=desc
    @GetMapping("list")
    public BaseRespVo commentList(BasePageInfo basePageInfo,Integer userId,Integer valueId) {
        PageHelper.startPage(basePageInfo.getPage(), basePageInfo.getLimit());
        List<MarketComment> list = adminCommmentService.getCommentList(basePageInfo,userId,valueId);
        PageInfo<MarketComment> pageInfo = new PageInfo<>(list);
        CommonData<MarketComment> data = CommonData.data(pageInfo);
        return BaseRespVo.ok(data);
    }

    @PostMapping("delete")
    public BaseRespVo commentDelete(@RequestBody MarketComment marketComment) {
        adminCommmentService.deleteComment(marketComment);
        return BaseRespVo.ok();

    }
}
